home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11666 < prev    next >
Encoding:
Text File  |  1996-08-05  |  896 b   |  35 lines

  1. Path: fohnix.metronet.com!not-for-mail
  2. From: milam@fohnix.metronet.com (Stan Milam)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Getting date in UNIX
  5. Date: 25 Mar 1996 13:23:31 -0600
  6. Organization: Texas Metronet, Inc  (login info (214/488-2590 - 817/571-0400))
  7. Message-ID: <4j6rrj$2bf@fohnix.metronet.com>
  8. References: <4ik447$bn7@raffles.technet.sg>
  9. NNTP-Posting-Host: fohnix.metronet.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Leonard Sim (leonard@pacific.net.sg) wrote:
  13. : Can anyone please inform me how to obtain the date in UNIX C??
  14. : I just need the date in this format "dd/mm/yyyy". Thanks!!!
  15.  
  16.  
  17. : rdgs,
  18.  
  19. : Leonard Sim
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <time.h>
  24.  
  25. int main( void ) {
  26.  
  27.     time_t time_v;
  28.     char   buffer[80], format[] ="%d/%m/%Y";
  29.  
  30.     time( &time_v );
  31.     strftime( buffer, sizeof(buffer), format, localtime( &time_v ) );
  32.     puts( buffer );
  33.     return EXIT_SUCCESS;
  34. }
  35.